// https://segmentfault.com/a/1190000018077543
const xlsx = require('xlsx');
const fs = require('fs');
const { readFileSync } = require('fs');

// 读取表格
let read = (name) => {
  let result = [];
  name.forEach((file, i) => {
    let dir = `./direction/${file}`
    const excelBuffer = readFileSync(dir);
    result[i] = xlsx.read(excelBuffer, {
      type: 'buffer',
      cellHTML: false,
    });
  });

  console.log('TCL: result', result);
}
// 获取所有文件名
const files = fs.readdirSync('./direction');
console.log(files);
read(files);
// https://www.cnblogs.com/vicky-li/p/11469100.html
// https://blog.csdn.net/weixin_46099269/article/details/113973433

/***
 * 如果出现Error: ENOSPC: System limit for number of file watchers错误
 * 是文件监视程序的系统产生了限制，达到了默认的上限，需要增加限额。
 *
 * 查看限额
 * cat /proc/sys/fs/inotify/max_user_watches
 * 
 * 临时更改限额
 * sudo sysctl fs.inotify.max_user_watches=524288
 * sudo sysctl -p
 * 
 * 永久增加限额
 * echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
 * sudo sysctl -p
 */

